/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.devmng.service;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.service.ServiceException;
import com.thinkgem.jeesite.modules.devmng.dao.DevchkItemDao;
import com.thinkgem.jeesite.modules.devmng.entity.*;
import com.thinkgem.jeesite.modules.devmng.vo.*;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.*;

/**
 * 检修项Service
 *
 * @author panda
 * @version 2017-12-02
 */
@Service
@Transactional(readOnly = true)
public class DevchkItemService extends CrudService<DevchkItemDao, DevchkItem> {

    public static final String MULTI_MEATURE_1 = "multiMeature1";
    public static final String MULTI_MEATURE_2 = "multiMeature2";
    public static final String MULTI_MEATURE_3 = "multiMeature3";
    public static final String MULTI_MEATURE_4 = "multiMeature4";
    public static final String MULTI_MEATURE_5 = "multiMeature5";
    public static final String MULTI_MEATURE_6 = "multiMeature6";
    public static final String MULTI_MEATURE_7 = "multiMeature7";
    public static final String MULTI_MEATURE_8 = "multiMeature8";
    public static final String MULTI_MEATURE_9 = "multiMeature9";
    public static final String MULTI_MEATURE_10 = "multiMeature10";
    @Autowired
    private DevchkAnswerService devchkAnswerService;

    @Autowired
    private DevchkItemAnswerService devchkItemAnswerService;

    @Autowired
    private DevchkAnswerItemService devchkAnswerItemService;

    @Autowired
    private TaskExecRecordService taskExecRecordService;

    @Autowired
    private TaskExecRecordAttaService taskExecRecordAttaService;

    public List<DevchkItemVo> viewResult(String taskMainId,
                                         String deviceMainId) {
        List<DevchkItemVo> devchkItemVoList = this.findListByTaskMainIdAndDeviceMainId(taskMainId, deviceMainId);

        TaskExecRecord taskExecRecord = new TaskExecRecord();
        taskExecRecord.setTaskMainId(taskMainId);
        taskExecRecord.setDeviceMainId(deviceMainId);
        List<TaskExecRecord> taskExecRecordList = taskExecRecordService.findList(taskExecRecord);

        Map<String, List<TaskExecRecordVo>> taskExecRecordVoMap = getTaskExecRecordVoMap(taskExecRecordList);

        TaskExecRecordAtta taskExecRecordAtta = new TaskExecRecordAtta();
        taskExecRecordAtta.setTaskMainId(taskMainId);
        taskExecRecordAtta.setDeviceMainId(deviceMainId);
        List<TaskExecRecordAtta> taskExecRecordAttaList = taskExecRecordAttaService.findList(taskExecRecordAtta);

        Map<String, List<String>> attaUrlMap = getAttaUrlListMap(taskExecRecordAttaList);

        for (DevchkItemVo devchkItemVo : devchkItemVoList) {
            List<DevchkAnswerVo> devchkAnswerVoList = devchkItemVo.getDevchkAnswerList();
            for (DevchkAnswerVo devchkAnswerVo : devchkAnswerVoList) {
                // 设置答案
                List<TaskExecRecordVo> taskExecRecordVoList = devchkAnswerVo.getTaskExecRecordVoList();
                if (taskExecRecordVoList == null) {
                    taskExecRecordVoList = new ArrayList<TaskExecRecordVo>();
                    devchkAnswerVo.setTaskExecRecordVoList(taskExecRecordVoList);
                }
                List<TaskExecRecordVo> taskExecRecordVoListFromMap = taskExecRecordVoMap.get(getAttaUrlKey(taskMainId, deviceMainId, devchkAnswerVo.getDevchkItemId(), devchkAnswerVo.getId()));
                if (taskExecRecordVoListFromMap != null) {
                    taskExecRecordVoList.addAll(taskExecRecordVoListFromMap);
                }
                // 设置图片url信息
                List<String> attaUrlList = devchkAnswerVo.getAttaUrlList();
                if (attaUrlList == null) {
                    attaUrlList = new ArrayList<String>();
                    devchkAnswerVo.setAttaUrlList(attaUrlList);
                }
                List<String> attaUrlListFromMap = attaUrlMap.get(getAttaUrlKey(taskMainId, deviceMainId, devchkAnswerVo.getDevchkItemId(), devchkAnswerVo.getId()));
                if (attaUrlListFromMap != null) {
                    attaUrlList.addAll(attaUrlListFromMap);
                }
            }
        }

        return devchkItemVoList;
    }

    private Map<String, List<TaskExecRecordVo>> getTaskExecRecordVoMap(List<TaskExecRecord> taskExecRecordList) {
        Map<String, List<TaskExecRecordVo>> result = new HashMap<String, List<TaskExecRecordVo>>();
        for (TaskExecRecord taskExecRecord : taskExecRecordList) {
            String key = getAttaUrlKey(taskExecRecord.getTaskMainId(), taskExecRecord.getDeviceMainId(),
                    taskExecRecord.getDevchkItemId(), taskExecRecord.getDevchkAnswerId());
            List<TaskExecRecordVo> taskExecRecordVoList = result.get(key);
            if (taskExecRecordVoList == null) {
                taskExecRecordVoList = new ArrayList<TaskExecRecordVo>();
                result.put(key, taskExecRecordVoList);
            }
            TaskExecRecordVo vo = new TaskExecRecordVo();
            vo.setId(taskExecRecord.getId());
            vo.setDevchkAnswerItemId(taskExecRecord.getDevchkAnswerItemId());
            vo.setNumContent(taskExecRecord.getNumContent());
            vo.setTextContent(taskExecRecord.getTextContent());
            taskExecRecordVoList.add(vo);
        }
        return result;
    }

    private Map<String, List<String>> getAttaUrlListMap(List<TaskExecRecordAtta> taskExecRecordAttaList) {
        Map<String, List<String>> result = new HashMap<String, List<String>>();
        for (TaskExecRecordAtta atta : taskExecRecordAttaList) {
            String key = getAttaUrlKey(atta.getTaskMainId(), atta.getDeviceMainId(),
                    atta.getDevchkItemId(), atta.getDevchkAnswerId());
            List<String> attaUrlList = result.get(key);
            if (attaUrlList == null) {
                attaUrlList = new ArrayList<String>();
                result.put(key, attaUrlList);
            }
            attaUrlList.add(atta.getAttaUrl());
        }
        return result;
    }

    private String getAttaUrlKey(String taskMainId, String deviceMainId, String devchkItemId, String devchkAnswerId) {
        return taskMainId + "_"
                + deviceMainId + "_"
                + devchkItemId + "_"
                + devchkAnswerId;
    }

    public List<DevchkItemVo> findListByTaskMainIdAndDeviceMainId(String taskMainId,
                                                                  String deviceMainId) {
        // 获取检修项列表
        List<DevchkItemVo> devchkItemVoList = this.dao.findListByTaskMainIdAndDeviceMainId(taskMainId, deviceMainId);
        if (devchkItemVoList.size() == 0) {
            return Collections.emptyList();
        }
        List<String> devchkItemIdList = new ArrayList<String>();
        for (DevchkItemVo devchkItemVo : devchkItemVoList) {
            devchkItemIdList.add(devchkItemVo.getId());
        }
        // 获取检修项答案
        List<DevchkAnswerWithDevchkItemId> devchkItemAnswerList = devchkAnswerService.findListByDevchkItemIdList(devchkItemIdList);
        if (devchkItemAnswerList.size() == 0) {
            return devchkItemVoList;
        }
        Map<String, DevchkAnswerWithDevchkItemId> devchkAnswerIdMap = new HashMap<String, DevchkAnswerWithDevchkItemId>();
        for (DevchkAnswerWithDevchkItemId devchkAnswerWithDevchkItemId : devchkItemAnswerList) {
            devchkAnswerWithDevchkItemId.setUnitCodeDesc(DictUtils.getDictLabel(devchkAnswerWithDevchkItemId.getUnitCode(), "MEATURE_UNIT", ""));
            if (devchkAnswerWithDevchkItemId.getMinValue() != null || devchkAnswerWithDevchkItemId.getMaxValue() != null) {
                if (devchkAnswerWithDevchkItemId.getMinValue() == null) {
                    devchkAnswerWithDevchkItemId.setMinValue(BigDecimal.valueOf(-999999));
                }
                if (devchkAnswerWithDevchkItemId.getMaxValue() == null) {
                    devchkAnswerWithDevchkItemId.setMaxValue(BigDecimal.valueOf(999999));
                }
                devchkAnswerWithDevchkItemId.setValueAlarm("Y");
            } else {
                devchkAnswerWithDevchkItemId.setValueAlarm("N");
            }
            devchkAnswerIdMap.put(devchkAnswerWithDevchkItemId.getDevchkItemId() + "_" + devchkAnswerWithDevchkItemId.getId(), devchkAnswerWithDevchkItemId);
        }
        List<DevchkAnswerVo> devchkAnswerVoList = new ArrayList<>();
        List<String> devchkAnswerIdList = new ArrayList<>();
        for (DevchkAnswerWithDevchkItemId devchkAnswer : devchkItemAnswerList) {
            DevchkAnswerVo vo = new DevchkAnswerVo();
            vo.setId(devchkAnswer.getId());
            vo.setDevchkItemId(devchkAnswer.getDevchkItemId());
            vo.setAnswerType(devchkAnswer.getAnswerType());
            devchkAnswerVoList.add(vo);
            devchkAnswerIdList.add(devchkAnswer.getId());
        }
        // 获取检修项答案的选项
        List<DevchkAnswerItem> devchkAnswerItemList = devchkAnswerItemService.findListByDevchkAnswerIdList(devchkAnswerIdList);
        if (devchkAnswerItemList.size() == 0) {
            return devchkItemVoList;
        }
        List<DevchkAnswerItemVo> devchkAnswerItemVoList = new ArrayList<DevchkAnswerItemVo>();
        for (DevchkAnswerItem devchkAnswerItem : devchkAnswerItemList) {
            DevchkAnswerItemVo vo = new DevchkAnswerItemVo();
            vo.setId(devchkAnswerItem.getId());
            vo.setAnsItemContent(devchkAnswerItem.getAnsItemContent());
            vo.setDevchkAnswerId(devchkAnswerItem.getDevchkAnswerId());
            devchkAnswerItemVoList.add(vo);
        }
        // 组合DevchkAnswerVo对象和DevchkAnswerItemVo对象的关系
        for (DevchkAnswerVo devchkAnswerVo : devchkAnswerVoList) {
            for (DevchkAnswerItemVo devchkAnswerItemVo : devchkAnswerItemVoList) {
                if (StringUtils.equals(devchkAnswerItemVo.getDevchkAnswerId(), devchkAnswerVo.getId())) {
                    List<DevchkAnswerItemVo> devchkAnswerItemVoList1 = devchkAnswerVo.getDevchkAnswerItemVoList();
                    if (devchkAnswerItemVoList1 == null) {
                        devchkAnswerItemVoList1 = new ArrayList<DevchkAnswerItemVo>();
                        devchkAnswerVo.setDevchkAnswerItemVoList(devchkAnswerItemVoList1);
                    }
                    devchkAnswerItemVoList1.add(devchkAnswerItemVo.clone());
                }
            }
        }
        // 组合DevchkItem对象和DevchkAnswerVo对象的关系
        for (DevchkItemVo devchkItemVo : devchkItemVoList) {
            for (DevchkAnswerVo devchkAnswerVo : devchkAnswerVoList) {
                if (StringUtils.equals(devchkItemVo.getId(), devchkAnswerVo.getDevchkItemId())) {
                    List<DevchkAnswerVo> devchkAnswerList = devchkItemVo.getDevchkAnswerList();
                    if (devchkAnswerList == null) {
                        devchkAnswerList = new ArrayList<DevchkAnswerVo>();
                        devchkItemVo.setDevchkAnswerList(devchkAnswerList);
                    }
                    devchkAnswerList.add(devchkAnswerVo);
                }
            }
        }

        for (DevchkItemVo devchkItemVo : devchkItemVoList) {
            for (DevchkAnswerVo devchkAnswerVo : devchkItemVo.getDevchkAnswerList()) {
                if (devchkAnswerVo.getDevchkAnswerItemVoList() == null) {
                    continue;
                }
                for (DevchkAnswerItemVo devchkAnswerItemVo : devchkAnswerVo.getDevchkAnswerItemVoList()) {
                    DevchkAnswerWithDevchkItemId devchkAnswerWithDevchkItemId = devchkAnswerIdMap.get(devchkItemVo.getId() + "_" + devchkAnswerItemVo.getDevchkAnswerId());
                    if (devchkAnswerWithDevchkItemId != null && StringUtils.isNotEmpty(devchkAnswerWithDevchkItemId.getContentDesc())) {
                        devchkAnswerItemVo.setAnsItemContent(devchkAnswerWithDevchkItemId.getContentDesc());
                        devchkAnswerItemVo.setUnitCodeDesc(devchkAnswerWithDevchkItemId.getUnitCodeDesc());
                        devchkAnswerItemVo.setValueAlarm(devchkAnswerWithDevchkItemId.getValueAlarm());
                        devchkAnswerItemVo.setMinValue(devchkAnswerWithDevchkItemId.getMinValue());
                        devchkAnswerItemVo.setMaxValue(devchkAnswerWithDevchkItemId.getMaxValue());
                    }
//                    else {
//                        devchkAnswerItemVo.setAnsItemContent(devchkAnswerItemVo.getAnsItemContent());
//                    }
                }
            }
        }
        return devchkItemVoList;
    }

    public DevchkItem get(String id) {
        DevchkItem devchkItem = super.get(id);
        if (devchkItem != null) {
            List<DevchkAnswer> devchkAnswers = devchkAnswerService.getByDevchkItemId(devchkItem.getId());
            devchkItem.setDevchkAnswers(devchkAnswers);
        }
        return devchkItem;
    }

    public List<DevchkItem> findList(DevchkItem devchkItem) {
        return super.findList(devchkItem);
    }

    public Page<DevchkItem> findPage(Page<DevchkItem> page, DevchkItem devchkItem) {
        return super.findPage(page, devchkItem);
    }

    @Transactional(readOnly = false)
    public void superSave(DevchkItem devchkItem) {
        super.save(devchkItem);
    }

    @Transactional(readOnly = false)
    public void save(DevchkItem devchkItem) {
        super.save(devchkItem);
        List<DevchkItemAnswer> devchkItemAnswerList = new ArrayList<DevchkItemAnswer>();
        for (DevchkAnswer devchkAnswer : devchkItem.getDevchkAnswers()) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId(devchkAnswer.getId());
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            if ("1".equals(devchkItemAnswer.getDevchkAnswerId())) {  // 正常/不正常选项
                devchkItemAnswer.setSortNum(10);
            } else if ("4".equals(devchkItemAnswer.getDevchkAnswerId())) { // 图片选项
                devchkItemAnswer.setSortNum(200);
            } else if ("3".equals(devchkItemAnswer.getDevchkAnswerId())) { // 备注选项
                devchkItemAnswer.setSortNum(999);
            }
            devchkItemAnswerList.add(devchkItemAnswer);
        }
        if (DevchkItem.Meature.noneMeature.name().equals(devchkItem.getMeature())) {
            // do nothing
        } else if (DevchkItem.Meature.singleMeature.name().equals(devchkItem.getMeature())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("2"); // 单个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getSingleMeatureContentDesc() == null ? "测量值" : devchkItem.getSingleMeatureContentDesc());
            devchkItemAnswer.setUnitCode(devchkItem.getSingleMeatureUnitCode());
            devchkItemAnswer.setTag(DevchkItem.Meature.singleMeature.name());
            devchkItemAnswer.setSortNum(50);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue());
            devchkItemAnswerList.add(devchkItemAnswer);
        } else if (DevchkItem.Meature.multiMeature.name().equals(devchkItem.getMeature())) {
            setMultiDevchkItemAnswer(devchkItem, devchkItemAnswerList);
        }
        if (devchkItemAnswerList.size() <= 1) {
            throw new ServiceException("没有设置回答！");
        }
        //  删除旧数据并新增新数据
        devchkItemAnswerService.deleteByDevchkItemId(devchkItem.getId());
        for (DevchkItemAnswer devchkItemAnswer : devchkItemAnswerList) {
            devchkItemAnswerService.save(devchkItemAnswer);
        }
    }

    private void setMultiDevchkItemAnswer(DevchkItem devchkItem, List<DevchkItemAnswer> list) {
        if (StringUtils.isNotBlank(devchkItem.getMultiMeatureContentDesc1())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("5"); // 多个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getMultiMeatureContentDesc1());
            devchkItemAnswer.setUnitCode(devchkItem.getMultiMeatureUnitCode1());
            devchkItemAnswer.setTag(MULTI_MEATURE_1);
            devchkItemAnswer.setSortNum(60);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue1());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue1());
            list.add(devchkItemAnswer);
        }
        if (StringUtils.isNotBlank(devchkItem.getMultiMeatureContentDesc2())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("6"); // 多个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getMultiMeatureContentDesc2());
            devchkItemAnswer.setUnitCode(devchkItem.getMultiMeatureUnitCode2());
            devchkItemAnswer.setTag(MULTI_MEATURE_2);
            devchkItemAnswer.setSortNum(70);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue2());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue2());
            list.add(devchkItemAnswer);
        }
        if (StringUtils.isNotBlank(devchkItem.getMultiMeatureContentDesc3())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("7"); // 多个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getMultiMeatureContentDesc3());
            devchkItemAnswer.setUnitCode(devchkItem.getMultiMeatureUnitCode3());
            devchkItemAnswer.setTag(MULTI_MEATURE_3);
            devchkItemAnswer.setSortNum(80);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue3());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue3());
            list.add(devchkItemAnswer);
        }
        if (StringUtils.isNotBlank(devchkItem.getMultiMeatureContentDesc4())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("8"); // 多个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getMultiMeatureContentDesc4());
            devchkItemAnswer.setUnitCode(devchkItem.getMultiMeatureUnitCode4());
            devchkItemAnswer.setTag(MULTI_MEATURE_4);
            devchkItemAnswer.setSortNum(90);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue4());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue4());
            list.add(devchkItemAnswer);
        }
        if (StringUtils.isNotBlank(devchkItem.getMultiMeatureContentDesc5())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("9"); // 多个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getMultiMeatureContentDesc5());
            devchkItemAnswer.setUnitCode(devchkItem.getMultiMeatureUnitCode5());
            devchkItemAnswer.setTag(MULTI_MEATURE_5);
            devchkItemAnswer.setSortNum(100);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue5());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue5());
            list.add(devchkItemAnswer);
        }
        if (StringUtils.isNotBlank(devchkItem.getMultiMeatureContentDesc6())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("10"); // 多个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getMultiMeatureContentDesc6());
            devchkItemAnswer.setUnitCode(devchkItem.getMultiMeatureUnitCode6());
            devchkItemAnswer.setTag(MULTI_MEATURE_6);
            devchkItemAnswer.setSortNum(110);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue6());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue6());
            list.add(devchkItemAnswer);
        }
        if (StringUtils.isNotBlank(devchkItem.getMultiMeatureContentDesc7())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("11"); // 多个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getMultiMeatureContentDesc7());
            devchkItemAnswer.setUnitCode(devchkItem.getMultiMeatureUnitCode7());
            devchkItemAnswer.setTag(MULTI_MEATURE_7);
            devchkItemAnswer.setSortNum(120);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue7());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue7());
            list.add(devchkItemAnswer);
        }
        if (StringUtils.isNotBlank(devchkItem.getMultiMeatureContentDesc8())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("12"); // 多个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getMultiMeatureContentDesc8());
            devchkItemAnswer.setUnitCode(devchkItem.getMultiMeatureUnitCode8());
            devchkItemAnswer.setTag(MULTI_MEATURE_8);
            devchkItemAnswer.setSortNum(130);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue8());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue8());
            list.add(devchkItemAnswer);
        }
        if (StringUtils.isNotBlank(devchkItem.getMultiMeatureContentDesc9())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("13"); // 多个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getMultiMeatureContentDesc9());
            devchkItemAnswer.setUnitCode(devchkItem.getMultiMeatureUnitCode9());
            devchkItemAnswer.setTag(MULTI_MEATURE_9);
            devchkItemAnswer.setSortNum(140);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue9());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue9());
            list.add(devchkItemAnswer);
        }
        if (StringUtils.isNotBlank(devchkItem.getMultiMeatureContentDesc10())) {
            DevchkItemAnswer devchkItemAnswer = new DevchkItemAnswer();
            devchkItemAnswer.setDevchkAnswerId("14"); // 多个测量值ID
            devchkItemAnswer.setDevchkItemId(devchkItem.getId());
            devchkItemAnswer.setContentDesc(devchkItem.getMultiMeatureContentDesc10());
            devchkItemAnswer.setUnitCode(devchkItem.getMultiMeatureUnitCode10());
            devchkItemAnswer.setTag(MULTI_MEATURE_10);
            devchkItemAnswer.setSortNum(150);
            devchkItemAnswer.setMinValue(devchkItem.getMinValue10());
            devchkItemAnswer.setMaxValue(devchkItem.getMaxValue10());
            list.add(devchkItemAnswer);
        }
    }

    @Transactional(readOnly = false)
    public void delete(DevchkItem devchkItem) {
        super.delete(devchkItem);
    }

}